package com.ruibang.glass.material.service.impl.cp;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruibang.glass.material.domain.req.bcp.ManageBCPLocationReq;
import com.ruibang.glass.material.entity.cp.MaterialCPLocationManagement;
import com.ruibang.glass.material.mapper.cp.GMaterialCPLocationManagementMapper;
import com.ruibang.glass.material.service.cp.GMaterialCPLocationManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 原材料库位管理表 服务实现类
 * </p>
 *
 * @author mameng
 * @since 2024-04-01
 */
@Service
public class GMaterialCPLocationManagementServiceImpl extends ServiceImpl<GMaterialCPLocationManagementMapper, MaterialCPLocationManagement> implements GMaterialCPLocationManagementService {

    @Override
    public IPage<MaterialCPLocationManagement> getPage(ManageBCPLocationReq manageLocationReq) {
        LambdaQueryWrapper<MaterialCPLocationManagement> queryWrapper = Wrappers.<MaterialCPLocationManagement>lambdaQuery();
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialCPLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getLocationName())) {
            queryWrapper.like(MaterialCPLocationManagement::getLocationName, manageLocationReq.getLocationName());
        }
        if (StringUtils.isNotBlank(manageLocationReq.getStatus())) {
            queryWrapper.like(MaterialCPLocationManagement::getStatus, manageLocationReq.getStatus());
        }
        Page<MaterialCPLocationManagement> materialWarehouseInfoPage = baseMapper.selectPage(new Page<>(manageLocationReq.getPageNo(), manageLocationReq.getPageSize()),
                queryWrapper.orderByDesc(MaterialCPLocationManagement::getCreateTime)
        );
        return materialWarehouseInfoPage;
    }
}
